package net.icontents.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import net.icontents.beans.Catalog;
import net.icontents.dao.CatalogDao;
import net.icontents.service.CatalogService;

@Service
public class CatalogServiceImpl extends BaseServiceImpl<Catalog> implements CatalogService {

	@Resource
	private CatalogDao catalogDao;
	
	@Override
	public void setBaseDaoHandlewired() {
		setBaseDao(catalogDao);
	}
	
	public List<Catalog> select(int page,int size){
		List<Catalog> catalogList = super.select(page, size);
		
		for(Catalog catalog:catalogList){
			catalog.setSubCatalogList(selectSubCatalog(catalog.getId()));
		}
		return catalogList;
	}

	@Override
	public List<Catalog> selectSubCatalog(int parentId) {
		return catalogDao.selectSubCatalog(parentId);
	}
}
